﻿<?php

$dom = new DOMDocument();
$dom->load("http://apis.daum.net/dic/endic?apikey=18fc40ef958f3884a28046a2f3f6c9197516d4f1&output=xml&kind=WORD&q=place");

//$dom->save("domtest.xml"); //xml파일을 그대로 저장한다.

foreach($dom->documentElement->childNodes as $channel){
    if(($channel->nodeType == 1) && ($channel->nodeName == "item")){
        foreach($channel->childNodes as $theitem){
            if(($theitem->nodeType ==1)&&($theitem->nodeName == "title")){
                $thetitle = $theitem->textContent;
            }
            if(($theitem->nodeType ==1)&&($theitem->nodeName == "description")){
                $thedescription = $theitem->textContent;
            }
            if(($theitem->nodeType ==1)&&($theitem->nodeName == "pronunciation")){
                $thepronunciation = $theitem->textContent;
            }
        }
        echo  "책이름a : " .$thetitle ."<br>"." 책이름b : " .$thedescription ."<br>"."책 작가:". $thepronunciation."<br><br>";
        unset($theBookTitle);            
        unset($theBookTitleb);
        unset($theBookAuthor);
    }
}

//18fc40ef958f3884a28046a2f3f6c9197516d4f1

?>